<template>
  <Dialog v-model="dialogVisible" title="详情" width="900">
    <el-descriptions :column="1" :label-width="130" border>
      <el-descriptions-item label="日志编号">
        {{ detailData.id }}
      </el-descriptions-item>
      <el-descriptions-item label="操作人员">
        {{ detailData.userName }}
        <dict-tag
          v-if="detailData.userType"
          :options="common_user_type"
          :value="detailData.userType"
        />
        <span v-if="detailData.userId">（{{ detailData.userId }}）</span>
      </el-descriptions-item>
      <el-descriptions-item label="操作模块">
        {{ detailData.type }} / {{ detailData.subType }}
      </el-descriptions-item>
      <el-descriptions-item label="操作内容">
        {{ detailData.action }}
      </el-descriptions-item>
      <el-descriptions-item v-if="detailData.extra" label="扩展信息">
        {{ detailData.extra }}
      </el-descriptions-item>
      <el-descriptions-item label="业务数据编号">
        {{ detailData.bizId }}
      </el-descriptions-item>
      <el-descriptions-item label="请求URL">
        <el-tag type="info" disable-transitions>{{ detailData.requestMethod }}</el-tag>
        {{ detailData.requestUrl }}
      </el-descriptions-item>
      <el-descriptions-item label="终端信息">
        {{ detailData.userIp }}，{{ detailData.userAgent }}
      </el-descriptions-item>
      <el-descriptions-item label="操作时间">
        {{ detailData.operateTime }}
      </el-descriptions-item>
      <el-descriptions-item label="TraceId">
        {{ detailData.traceId }}
      </el-descriptions-item>
    </el-descriptions>
  </Dialog>
</template>

<script setup lang="ts">
import { OperateLogVO } from '@/api/system/operate_log'

defineOptions({ name: 'SystemOperateLogDetail' })

const { common_user_type } = useDict(DICT_TYPE.common_user_type)

const dialogVisible = ref(false) // 弹窗的是否展示
const detailData = ref<OperateLogVO>({} as OperateLogVO) // 详情数据

/** 打开弹窗 */
const open = async (data: OperateLogVO) => {
  dialogVisible.value = true
  detailData.value = data
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗
</script>

<style scoped lang="scss">

</style>
